<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>

    <title>地址管理</title>

    <meta name="address" content="地址管理">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <script src="/js/jquery.min.js"></script>

</head>
<body class="hold-transition">
<div id="map">
    <div class="content-header">
        <h1>首页
            <small>公司分布图</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }"><a href="bmap.html">首页</a></el-breadcrumb-item>
            <el-breadcrumb-item>公司分布图</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="box">
        <div style="height:15px">
            &nbsp;
            <a href="address.html">分布图</a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="bmap_message.html" style="color: black">详细信息</a>
        </div>
    </div>
    <div class="app-container">
        <div style="padding: 9px;">
            <div class="filter-container">
                <el-input placeholder="公司地址" v-model="pagination.queryString" style="width: 200px;"
                          class="filter-item"></el-input>
                <el-button @click="findByQueryString()" class="dalfBut">查询</el-button>
                <el-button type="primary" class="butT" @click="handleCreate()" id="rest">新建</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="name" label="公司地址" align="center"></el-table-column>
                <el-table-column prop="longitude" label="所在经度" align="center"></el-table-column>
                <el-table-column prop="latitude" label="所在纬度" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
            <!-- 新增标签弹层 -->
            <div class="add-form">
                <el-form ref="dataAddForm" :model="formData" label-position="right"
                         label-width="120px">
                    <el-dialog title="新增地图" :visible.sync="dialogFormVisible">
                        <el-container>
                            <iframe name="right" class="el-main" src="bmap_mini.html" width="100%" height="450px"
                                    frameborder="0"></iframe>
                        </el-container>
                    </el-dialog>
                </el-form>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>

<script>
    new Vue({
        el: '#map',
        data: {
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize: 10,//每页显示的记录数
                total: 0,//总记录数
                queryString: null//查询条件
            },
            dataList: [],//当前页要展示的分页列表数据
            formData: {},//表单数据
            dialogFormVisible: false,//增加表单是否可见
        },
        //钩子函数，VUE对象初始化完成后自动执行
        created() {
            this.findPage();
        },

        methods: {
            //分页查询
            findPage() {
                axios.post("/address/findPage.do", this.pagination).then((res) => {
                    this.pagination.total = res.data.total;
                    this.dataList = res.data.rows;
                });
            },
            //搜索
            findByQueryString() {
                this.pagination.currentPage = 1;
                this.findPage();
            },
            // 弹出添加窗口
            handleCreate(data) {
                this.formData={};
                this.dialogFormVisible = true;
            },

            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.findPage();
            },
            // 删除
            handleDelete(row) {
                this.$confirm("你确定要删除地址吗？", "确认删除", {
                    type: "warning"
                }).then(() => {
                    axios.get("/address/deleteAddress.do?id=" + row.id).then((res) => {
                        if (res.data.flag) {
                            this.$message({
                                type: "success",
                                message: res.data.message
                            })
                        } else {
                            this.$message.error(res.data.message);
                        }
                    }).finally(() => {
                        this.findPage();
                    });
                }).catch(() => {
                    this.$message({
                        type: "info",
                        message: "用户取消操作"
                    });
                });
            }
        }
    });
</script>

</html>
